package com.mdsoft.dao.context;

import java.util.ArrayList;
import java.util.List;

import com.mdsoft.context.Context;
import com.mdsoft.dao.ChooseDao;
import com.mdsoft.po.Choose;

public class ContextChooseDao implements ChooseDao {

	@SuppressWarnings("unchecked")
	@Override
	public void add(Choose choose) {

		List<Choose> chooses;
		
		Context context = Context.getInstance();
		Object obj = context.get(Context.CHOOSES);
		if (obj == null) {
			chooses = new ArrayList<Choose>();
			context.put(Context.CHOOSES, chooses);
		} else {
			chooses = (List<Choose>) obj;
		}
		
		choose.setId(context.nextSequence());
		chooses.add(choose);
	}

	@Override
	public List<Choose> getAll() {
		return (List<Choose>) Context.getInstance().get(Context.CHOOSES);
	}

	@Override
	public Choose get(int id) {
		return null;
	}

}
